]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/icon-theme: Replace g_get_current_time ()
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 1 Feb 2023 15:25:10 +0000 (16:25 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 2 Feb 2023 20:45:06 +0000 (20:45 +0000)
GTimeVal has been deprecated a while ago, don't let it sneak back
in via some old GTK code.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2620>

src/st/st-icon-theme.c

index 2a99c967eb89a0b95a51ff1e756b5b3b0b2dbdd3..223aecb6af7bf335ac392750438ead64fd504c20 100644 (file)
@@ -105,7 +105,7 @@ struct _GtkIconTheme
   GHashTable *unthemed_icons;
 
   /* time when we last stat:ed for theme changes */
-  glong last_stat_time;
+  int64_t last_stat_time;
   GList *dir_mtimes;
 
   guint theme_changed_idle;
@@ -1016,7 +1016,6 @@ load_themes (GtkIconTheme *icon_theme)
   int base;
   char *dir;
   const char *file;
-  GTimeVal tv;
   IconThemeDirMtime *dir_mtime;
   GStatBuf stat_buf;
   GList *d;
@@ -1088,14 +1087,12 @@ load_themes (GtkIconTheme *icon_theme)
 
   icon_theme->themes_valid = TRUE;
 
-  g_get_current_time (&tv);
-  icon_theme->last_stat_time = tv.tv_sec;
+  icon_theme->last_stat_time = g_get_monotonic_time ();
 }
 
 static void
 ensure_valid_themes (GtkIconTheme *icon_theme)
 {
-  GTimeVal tv;
   gboolean was_valid = icon_theme->themes_valid;
 
   if (icon_theme->loading_themes)
@@ -1104,9 +1101,9 @@ ensure_valid_themes (GtkIconTheme *icon_theme)
 
   if (icon_theme->themes_valid)
     {
-      g_get_current_time (&tv);
+      int64_t time = g_get_monotonic_time ();
 
-      if (ABS (tv.tv_sec - icon_theme->last_stat_time) > 5 &&
+      if (ABS (time - icon_theme->last_stat_time) > 5 * G_TIME_SPAN_SECOND &&
           rescan_themes (icon_theme))
         {
           g_hash_table_remove_all (icon_theme->info_cache);
@@ -2215,7 +2212,6 @@ rescan_themes (GtkIconTheme *icon_theme)
   GList *d;
   int stat_res;
   GStatBuf stat_buf;
-  GTimeVal tv;
 
   for (d = icon_theme->dir_mtimes; d != NULL; d = d->next)
     {
@@ -2236,8 +2232,7 @@ rescan_themes (GtkIconTheme *icon_theme)
       return TRUE;
     }
 
-  g_get_current_time (&tv);
-  icon_theme->last_stat_time = tv.tv_sec;
+  icon_theme->last_stat_time = g_get_monotonic_time ();
 
   return FALSE;
 }